<!--
 * @Author: your name
 * @Date: 2021-05-31 21:39:34
 * @LastEditTime: 2021-07-06 20:17:17
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \JS高级学习\js\array\27.html
-->
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <meta http-equiv="X-UA-Compatible" content="ie=edge" />
  <title>后盾人</title>
</head>

<body></body>
<script>
    // let arr = [1, 2, 3, 4, 5];
    // arr.reduce(function(pre, value, index, array) {
    //   console.log(pre, value);
    //   return 99;
    // });
    // arr.reduce(function(pre, value, index, array) {
    //   console.warn(pre, value);
    //   return 99;
    // }, 0);

    // let arr = [1, 2, 3, 1, 1];
    // function arrayCount(array, item) {
    //   return array.reduce(function(total, cur) {
    //     total += item == cur ? 1 : 0;
          //totatl= item===cur?total+1:0
    //     return total;
    //   }, 0);
    // }
    // console.log(arrayCount(arr, 1));

    // let arr = [1, 2, 3, 5, 2, 89];
    // function arrayMax(array) {
    //   return array.reduce(function(pre, cur) {
    //     return pre > cur ? pre : cur;
    //   });
    // }
    // console.log(arrayMax(arr));
      
</script>

</html>